<template>
    <aside class="create-center-sidebar">
      <!-- 侧边栏头部 -->
      <div class="sidebar-header">
        <div class="header-avatar">
          <el-icon><Setting /></el-icon>
          <div class="avatar-glow"></div>
        </div>
        <div class="header-info">
          <h3>创作中心</h3>
          <span class="status-badge">管理模式</span>
        </div>
      </div>
      
      <!-- 导航卡片 -->
      <div class="nav-cards">
        <div 
          :class="['nav-card', { active: activeMenu === 'forum-manager' }]"
          @click="handleMenuSelect('forum-manager')"
        >
          <div class="card-icon forum-icon">
            <el-icon><ChatDotRound /></el-icon>
          </div>
          <div class="card-content">
            <h4>论坛管理</h4>
            <p>管理帖子和评论</p>
          </div>
          <div class="card-arrow">
            <el-icon><ArrowRight /></el-icon>
          </div>
        </div>
        
        <div 
          :class="['nav-card', { active: activeMenu === 'resources-manager' }]"
          @click="handleMenuSelect('resources-manager')"
        >
          <div class="card-icon resources-icon">
            <el-icon><Files /></el-icon>
          </div>
          <div class="card-content">
            <h4>资源管理</h4>
            <p>管理文件和资料</p>
          </div>
          <div class="card-arrow">
            <el-icon><ArrowRight /></el-icon>
          </div>
        </div>
      </div>
      
      <!-- 统计信息（已移除） -->
      <!-- <div class="stats-section">
        <div class="stats-title">快速概览</div>
        <div class="stats-grid">
          <div class="stat-item">
            <div class="stat-number">12</div>
            <div class="stat-label">帖子</div>
          </div>
          <div class="stat-item">
            <div class="stat-number">8</div>
            <div class="stat-label">资源</div>
          </div>
        </div>
      </div> -->
    </aside>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Setting, ChatDotRound, Files, ArrowRight } from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()
const activeMenu = ref('forum-manager')

watch(
  () => route.name,
  (name) => {
    if (name === 'ForumManager') activeMenu.value = 'forum-manager'
    else if (name === 'ResourcesManager') activeMenu.value = 'resources-manager'
  },
  { immediate: true }
)

const handleMenuSelect = (key: string) => {
  if (key === 'forum-manager') router.push({ name: 'ForumManager' })
  else if (key === 'resources-manager') router.push({ name: 'ResourcesManager' })
}
</script>

<style scoped>
.create-center-layout {
  display: flex;
  min-height: calc(100vh - 80px);
  background: transparent; /* 修改为透明背景 */
  gap: 10px;
  padding: 20px;
  width:100%;
  margin: auto; /* 水平居中 */
  max-width: 1200px; /* 限制最大宽度，防止过宽 */
}

.create-center-sidebar {
  width: 250px;
  height:70%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.create-center-sidebar:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 头部样式 */
.sidebar-header {
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.header-avatar {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

.header-avatar:hover {
  transform: scale(1.05);
}

.header-avatar .el-icon {
  font-size: 28px;
  z-index: 2;
}

.avatar-glow {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
  border-radius: 18px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.header-avatar:hover .avatar-glow {
  opacity: 1;
}

.header-info h3 {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.status-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 导航卡片 */
.nav-cards {
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 16px;
}

.nav-card {
  background: transparent; /* 透明，继承父背景 */
  border: none;
  box-shadow: none;
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.nav-card.active {
  border: none;
  /* 选中时淡紫色高亮 */
  background: rgba(180, 143, 255, 0.18); /* #b48fff 淡紫色 */
  /* 可选：字体颜色变化 */
  color: #7f4fd4;
}

.nav-card:hover {
  border: none;
  box-shadow: none;
  background: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.nav-card::before,
.nav-card.active::before {
  display: none;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.forum-icon {
  background: linear-gradient(135deg, #7F7FD5 0%, #86A8E7 50%, #91EAE4 100%);
  color: #fff;
}

.resources-icon {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.nav-card:hover .card-icon {
  transform: scale(1.1);
}

.nav-card.active .card-icon {
  transform: scale(1.05);
}

.card-icon .el-icon {
  font-size: 24px;
}

.card-content {
  flex: 1;
}

.card-content h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.card-content p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.card-arrow {
  color: #cbd5e1;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateX(-8px);
}

.nav-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: #667eea;
}

.nav-card.active .card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: #667eea;
}

/* 统计信息 */
.stats-section {
  margin-top: auto;
  padding: 0 24px 24px;
}

.stats-title {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  transition: all 0.3s ease;
}

.stat-item:hover {
  background: white;
  border-color: #e2e8f0;
  transform: translateY(-1px);
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

/* 主内容区域 */
.create-center-main {
  flex: 1;
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.create-center-main:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .create-center-sidebar {
    width: 280px;
  }
  
  .sidebar-header {
    padding: 20px;
  }
  
  .nav-cards {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .create-center-layout {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }
  
  .create-center-sidebar {
    width: 100%;
    order: 2;
  }
  
  .create-center-main {
    order: 1;
  }
  
  .sidebar-header {
    padding: 20px;
  }
  
  .header-info h3 {
    font-size: 20px;
  }
  
  .nav-cards {
    padding: 20px;
    gap: 10px;
  }
  
  .nav-card {
    padding: 16px;
  }
  
  .card-icon {
    width: 40px;
    height: 40px;
  }
  
  .card-icon .el-icon {
    font-size: 20px;
  }
  
  .card-content h4 {
    font-size: 15px;
  }
  
  .card-content p {
    font-size: 12px;
  }
  
  .stats-section {
    padding: 0 20px 20px;
  }
  
  .stat-item {
    padding: 12px;
  }
  
  .stat-number {
    font-size: 20px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-card {
  animation: fadeInUp 0.4s ease forwards;
}

.nav-card:nth-child(1) {
  animation-delay: 0.1s;
}

.nav-card:nth-child(2) {
  animation-delay: 0.2s;
}

.stats-section {
  animation: fadeInUp 0.4s ease 0.3s both;
}

/* 滚动条样式 */
.create-center-sidebar::-webkit-scrollbar {
  width: 4px;
}

.create-center-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.create-center-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.create-center-sidebar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
</style>
